package fulbiNet.servlet;

import java.io.IOException;
import java.text.SimpleDateFormat;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import fulbiNet.execpcion.DAOExcepcion;
import fulbiNet.modelo.Cancha;
import fulbiNet.modelo.Cliente;
import fulbiNet.modelo.Distrito;
import fulbiNet.modelo.Dueno;
import fulbiNet.modelo.Local;
import fulbiNet.modelo.Persona;
import fulbiNet.negocio.CrearCanchaNegocio;
import fulbiNet.negocio.CrearClienteNegocio;

/**
 * Servlet implementation class RegistrarCanchaServlet
 */
@WebServlet("/RegistrarCanchaServlet")
public class RegistrarCanchaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistrarCanchaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		SimpleDateFormat format=new SimpleDateFormat("dd/MM/yyy HH:mm");
		//Negocio Crear Cliente Negocio -
		

		String caracteristicas  = request.getParameter("caracte");
		String local = request.getParameter("local");
		String duenio  = request.getParameter("dueno");

		
		System.out.println(local);
		System.out.println(duenio);
		
		
		CrearCanchaNegocio neg = new CrearCanchaNegocio();			
		Cancha vo = new Cancha();
		vo.setCaracteristicas(caracteristicas) ;
		
		Dueno oDueno = new Dueno();
		oDueno.setCodigo(Integer.parseInt(duenio));
		vo.setoDueno(oDueno);
		
		Local oLocal = new Local();
		oLocal.setCodigo(Integer.parseInt(local));
		vo.setoLocal(oLocal);
		vo.setTarifa(0);
		vo.setEstado(1);		
		
		try {
			neg.insertarCancha(vo);
			response.sendRedirect(request.getContextPath() + "/menu.jsp");
		} catch (DAOExcepcion e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
